$ = function (id) {
	return document.getElementById(id);
};

Grantsfire = {
	toggleGrantVisualization: function () {
		var visDiv = $('searchResultVisInner');
		var showHideVisButton = $('toggleGrantVisButton');
		
		if (! visDiv || ! showHideVisButton)
			return;
			
		if (visDiv.style.display != "none") {
			visDiv.style.display = "none";
			showHideVisButton.alt = "Show Visualization";
			showHideVisButton.src = "/static/images/vis_open.png";
		} else {
			visDiv.style.display = "block";
			showHideVisButton.alt = "Hide Visualization";
			showHideVisButton.src = "/static/images/vis_close.png";
		}
		
		return false;
	},
	
	showSearchChart: function () {
		Grantsfire.toggleGrantVisualizationContainer("toggleChartButton");
	},
	
	showSearchMap: function () {
		Grantsfire.toggleGrantVisualizationContainer("toggleMapButton");
		
		if (! Grantsfire.mapInit) {
			Grantsfire.maps.init("grantMap");
			Grantsfire.mapInit = true;
		}
	},
	
	toggleGrantVisualizationContainer: function (container) {
		if (container == "toggleChartButton") {
			$("toggleChartButton").className = "tab";
			$("toggleMapButton").className = "tab disabledTab";
			$("searchResultMapInner").style.display = "none";
			$("searchResultChartInner").style.display = "block";
		} else {
			$("toggleChartButton").className = "tab disabledTab";
			$("toggleMapButton").className = "tab";
			$("searchResultMapInner").style.display = "block";
			$("searchResultChartInner").style.display = "none";
		}
	}
};
